<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../static/resources/bootstrap/css/bootstrap.css" rel="stylesheet">
    <!-- jQuery -->
    <script type="text/javascript" src="../static/resources/js/jquery/jquery-1.9.0.min.js"></script>
    <!-- Bootstrap JS -->
    <script type="text/javascript" src="../static/resources/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div class="form-line form-username" style="display: block;">
        <label for="pwd1">请输入新密码:</label><input type="password" class="df-input-narrow" name="pwd1" id="pwd1">
    </div>
    <div class="form-line form-username" style="display: block;">
        <label for="pwd2">请确认新密码:</label><input type="password" class="df-input-narrow" name="pwd2" id="pwd2">
        <span id="msg"></span>
    </div>
    <input type="hidden" id="userId" value="${userId}">
    <div class="form-group">
        <div class="col-md-9 col-md-offset-3">
            <input type="button" value="确认" id="editBtn" class="btn btn-info">
            <input type="button" value="取消" id="cancleBtn" class="btn btn-info">
        </div>
    </div>
</div>
</body>
</html>
<script>
    var editPwd = function () {
      $.ajax({
          type:"POST",
          url:"/updUserPwd",
          data:{
              userId: $("#userId").val().replace(/,/g,''),
              password: $("#pwd2").val()
          },success:function (data) {
              if(data > 0){
                  $("#cancleBtn").click();
              }
          }
      });
    };

    $("#editBtn").click(function () {
        $("#msg").html();
        if($("#pwd1").val() == $("#pwd2").val()){
            editPwd();
        }else {
            $("#msg").html("<span class='glyphicon glyphicon-remove' style='color: red'></span>");
        }
    });

    $("#cancleBtn").click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.getUserByPage();
        parent.layer.close(index);
    });
</script>